package querier

import "gorm.io/gen"

type InventoryDimWarehouse interface {
	// SELECT COUNT(0) as count FROM
	// (SELECT A.*,B.id sub_id,B.name sub_name FROM wms_warehouse A left join wms_warehouse B on A.id=B.parent_id
	// WHERE A.parent_id=0) A
	// left join
	// (
	// SELECT A.*,B.sum_qty,B.wid,B.mark FROM wms_goods A left join
	// (
	// SELECT SUM(A.qty*A.mark) sum_qty, A.*  FROM wms_inventory A WHERE A.status=1
	// group by A.goods_id,A.wid
	// ) B ON A.id = B.goods_id
	// {{where}}
	// {{if goodsId > 0}}
	// AND A.id=@goodsId
	// {{end}}
	// {{end}}
	// ) B ON A.id=B.wid OR A.sub_id=B.wid
	// {{where}}
	// {{if wid > 0}}
	// A.id=@wid OR A.sub_id=@wid
	// {{end}}
	// {{end}}
	QueryInventoryByWarehouseTotal(wid, goodsId uint) (gen.M, error)

	// SELECT A.id,A.name warehouse_name,A.sub_name warehouse_area_name,B.* FROM
	// (SELECT A.*,B.id sub_id,B.name sub_name FROM wms_warehouse A left join wms_warehouse B on A.id=B.parent_id
	// WHERE A.parent_id=0) A
	// left join
	// (
	// SELECT A.*,B.sum_qty,B.wid,B.mark FROM wms_goods A left join
	// (
	// SELECT SUM(A.qty*A.mark) sum_qty, A.*  FROM wms_inventory A WHERE A.status=1
	// group by A.goods_id,A.wid
	// ) B ON A.id = B.goods_id
	// {{where}}
	// {{if goodsId > 0}}
	// AND A.id=@goodsId
	// {{end}}
	// {{end}}
	// ) B ON A.id=B.wid OR A.sub_id=B.wid
	// {{where}}
	// {{if wid > 0}}
	// A.id=@wid OR A.sub_id=@wid
	// {{end}}
	// {{end}}
	// LIMIT @start,@pageSize;
	QueryInventoryByWarehouse(wid, goodsId uint, start, pageSize int) ([]*gen.T, error)
}
